﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace DiscoveryLogic.UI.Layouts.Controls
{
    public static class Helpers
    {
        static int count; 
        public static string GetUnique(string prefix)
        {
            return prefix + count++; 
        } 
        public static void CenterX(FrameworkElement e, Canvas container)
        {
             Center(e, container, true, false); 
        }
        public static void CenterY(FrameworkElement e, Canvas container)
        {
            Center(e, container, false, true );
        }
        public static void Center(FrameworkElement e, Canvas container, bool x, bool y)
        {
            double width ,height ; 
            if ( ! ( e is TextBlock )) 
            { 
                width = e.Width ; 
                height = e.Height ; 
            } 
            else 
            { 
                TextBlock t = e as TextBlock ; 
                width= t.ActualWidth ; 
                height = t.ActualHeight  ; 
            } 
            if ( x ) 
                e.SetValue ( Canvas.LeftProperty , (container.Width - width)/2 ); 
            if ( y ) 
                e.SetValue ( Canvas.TopProperty , (container.Height - height)/2 ); 
        } 
    }
}
